<template>
	<view class="bottomBar">
		<uni-badge class="uni-badge-left-margin" :text="number" :offset="[10, 10]" absolute="rightTop" size="small">
			<view class="box">
				<image class="image" src="../static/icon/food.png" mode="aspectFit"></image>
			</view>
		</uni-badge>
		<view class="text">
			<text v-if="number==0">请添加食物哦</text>
			<text v-else>{{number}}种食物丨{{caloric}}千卡</text>
		</view>
		<view class="saveBtn" @click="saveBtn">
			<text>完成</text>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue';
	const emit = defineEmits(['click'])
	const props = defineProps({
		//右上角数量
		number: {
			type: Number,
			default: 0
		},
		//总热量
		caloric: {
			type: Number,
			default: 0
		}
	})
	const saveBtn = () => {
		emit("click", "saveBtn")
	}
</script>

<style lang="scss">
	.bottomBar {
		width: 100%;
		background: #fff;
		height: 10%;
		position: fixed;
		bottom: 0rpx;
		display: flex;
		box-shadow: 0rpx -5rpx 5rpx 0rpx rgba(0, 0, 0, 0.1);
		justify-content: space-between;

		.text {
			height: 70rpx;
			margin-left: 145rpx;
			font-size: 24rpx;
			color: #8a8b92;
			line-height: 70rpx;
		}

		.saveBtn {
			height: 70rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			letter-spacing: 20rpx;
			text-indent: 20rpx;
			font-size: 28rpx;
			background-color: #87C38F;
			color: #fbffee;
			width: 30%;
		}
	}

	.uni-badge-left-margin {
		position: fixed;
		left: 30rpx;
		bottom: calc(10% - 80rpx);

	}

	.box {
		width: 100rpx;
		height: 100rpx;
		border-radius: 50%;
		display: flex;
		justify-content: center;
		align-items: center;
		text-align: center;
		background-color: #DCDFE6;

		.image {
			width: 80rpx;
			height: 80rpx;
		}
	}
</style>